using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;

namespace GMME
{
    [DataContract]
    public class SelfPosition
    {
        // 坐标对象
        [DataMember(Name = "position")]
        public PlayerPosition Position
        {
            get;
            set;
        }

        // 朝向对象
        [DataMember(Name = "axis")]
        public Axis Axis
        {
            get;
            set;
        }

#if UNITY_ANDROID
        internal static SelfPosition ConvertSelfPosition(AndroidJavaObject javaObject)
        {
            SelfPosition selfPosition = new SelfPosition();
            if (javaObject != null)
            {
                Axis axis = javaObject.Call<Axis>("getAxis");
                selfPosition.Axis = axis;
                PlayerPosition position = javaObject.Call<PlayerPosition>("getPlayerPosition");
                selfPosition.Position = position;
            
                Debug.LogFormat("Axis={0}, Position={1}", selfPosition.Axis, selfPosition.Position);
            }
            return selfPosition;
        }
#endif
    }
}


